<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
</head>
<body>


    <script>
        // 定义对象
        var obj = {}
        // aaa  red 
       console.log(  obj["aaa"] );// undefined

        // 首次出现 aaa , 判断obj的aaa属性值是否未 undefined (第一次出现aaa就是undefined,因为obj是空对象)
        if( obj["aaa"] == undefined){
            // obj["aaa"] = true;
            obj["aaa"] = {count: 1 }
        }

        if( obj["red"] == undefined){
            obj["red"] = {count : 1 }
        }

        // console.log(obj);
        // 再次遇到 aaa 这个属性时
        if( obj["aaa"] == undefined){
            obj["aaa"] = {count: 1 }
        }else {
            // 设置 count属性值 自增一
            obj["aaa"].count += 1;
        }


        if( obj["red"] == undefined){
            obj["red"] = {count: 1 }
        }else {
            obj["red"].count += 1;
        }
        console.log(obj);

    </script>
</body>
</html>